<?php

namespace App\Http\Validate\Purchase;

use App\Http\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class PurchaseAgreement extends BaseValidate
{
    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'type' => 'required|in:1,2,3,4',
                'custom_id' => 'required',
                'contract_no' => 'required',
                'steel_attr_company_id' => 'required',
                'contract_date' => 'required',
                'weight' => 'required',
                'settle_model' => 'required|in:1,2,3',
                // 'price' => 'required|integer|gt:0',
                'invoice_type' => 'required|in:1,2',
                'pay_type' => 'required|in:1,2,3',
                'settle_company_id' => 'required',
                'contract_filepath' => 'required',
                'settle_cycle_date'=>'in:0,1,2,3',
                'settle_cycle_month'=>'in:0,1,2,3',
                'settle_cycle_type'=>'in:0,1,2'
            ];
            $this->message = [
                'type.required' => '参数错误',
                'type.in' => '参数非法',
                'custom_id.required' => '供应商信息未选择',
                'contract_no.required' => '合同编号未填写',
                'steel_attr_company_id.required' => '钢厂未选择',
                'contract_date.required' => '日期未选择',
                'weight.required' => '协议量未填写',
                'settle_model.required' => '结算模式未选择',
                'settle_model.in' => '结算模式非法参数',
                'price.required' => '单价未填写',
                'price.integer' => '单价需大于0',
                'price.gt' => '单价需大于0',
                'invoice_type.required' => '票据类型未选择',
                'invoice_type.in' => '票据类型非法参数',
                'pay_type.required' => '付款方式未选择',
                'pay_type.in' => '付款方式非法参数',
                'settle_company_id.required' => '结算公司未选择',
                'contract_filepath.required' => '合同扫描件未上传',
                'settle_cycle_date.in' => '结算周期参数错误',
                'settle_cycle_month.in' => '结算周期参数错误',
                'settle_cycle_type.in' => '结算周期参数错误',
            ];
        } else {
            $this->rule = [
                'type' => 'required',
                'custom_id' => 'required',
                'contract_no' => 'required',
                'steel_attr_company_id' => 'required',
                'contract_date' => 'required',
                'weight' => 'required',
                'settle_model' => 'required',
                'price' => 'required|integer|gt:0',
                'invoice_type' => 'required',
                'pay_type' => 'required',
                'settle_company_id' => 'required',
                'contract_filepath' => 'required',
            ];
            $this->message = [
                'type.required' => '参数错误',
                'custom_id.required' => '供应商信息未选择',
                'contract_no.required' => '合同编号未填写',
                'steel_attr_company_id.required' => '钢厂未选择',
                'contract_date.required' => '日期未选择',
                'weight.required' => '协议量未填写',
                'settle_model.required' => '结算模式未选择',
                'price.required' => '单价未填写',
                'price.integer' => '单价需大于0',
                'price.gt' => '单价需大于0',
                'invoice_type.required' => '票据类型未选择',
                'pay_type.required' => '付款方式未选择',
                'settle_company_id.required' => '结算公司未选择',
                'contract_filepath.required' => '合同扫描件未上传',
            ];
        }
    }
}
